#include	<stdio.h>
#include	<string.h>

char * mystrchr(char * str, char ch) {
	char * p;

	for( p = str; *p != ch && *p != '\0'; ++p );

	if( *p == '\0' )
		return NULL;

	return p;
}

int mystrlen(char *str) {
	char * p;
	int len = 0;

	for( p = str; *p; ++p, ++len );

	return len;
}

char * strip(char *str) {
	char * p;
	char * p1;
	for( p = str; *p == ' '; ++p );
	for( p1 = str + mystrlen(str) - 1; *p1 == ' '; --p1 );
	*++p1 = '\0';

	return p;
}

void mystrcpy(char * dst, char * src) {
	char * psrc;
	char * pdst;

	for( psrc = src, pdst = dst; *psrc != '\0'; *pdst++ = *psrc++ );
	*++pdst = '\0';
}

int main() {
	char		str[] = "   key     =        value    ";
	char	*	p;

	char		str1[100];
	char		str2[100];

	mystrcpy(str1, str);
	printf("str1 = %s\n", str1);
	printf("str1 length is %d\n", mystrlen(str1));

	p = mystrchr(str, '=');
	*p++ = '\0';

	printf("'%s'\n", strip(str));
	printf("'%s'\n", strip(p));

	return 0;
}
